package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.core.pojo.entity.Lend;
import com.atguigu.srb.core.service.LendService;
import com.atguigu.srb.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author fun
 * @since 2021-10-29
 */
@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {
    @Autowired
    LendService lendService;

    @GetMapping("/list")
    public R list(){
        List<Lend> lendList  = lendService.getList();
        return R.ok().data("list",lendList);
    }

    @GetMapping("/show/{id}")
    public R show(@PathVariable("id") Long id){
        Map<String,Object> lendDetail = lendService.show(id);
        return R.ok().data("lendDetail",lendDetail);
    }

    /**
     * 放款
     * @param id
     * @return
     */
    @GetMapping("/makeLoan/{id}")
    public R makeLoan(@PathVariable("id") Long id){
        lendService.makeLoan(id);
        return R.ok();
    }

}

